// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RobotiqSModelBasicCommand.cs" company="Microsoft Corporation">
// The MIT License (MIT)
// 
// Copyright (c) 2014, Microsoft Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace Microsoft.Robotics.Hardware.Robotiq
{
    using System.Runtime.Serialization;

    /// <summary>
    /// Holds a basic (finger actions are coordinated from a single position reference) command
    /// for the Robotiq S Model.
    /// </summary>
    [DataContract]
    public class RobotiqSModelBasicCommand
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="RobotiqSModelBasicCommand" /> class.
        /// </summary>
        /// <param name="activation">Desired activation status.</param>
        /// <param name="gripMode">Desired grip mode.</param>
        /// <param name="goToPosition">Desired value of go to position flag.</param>
        /// <param name="position">Desired position.</param>
        /// <param name="speed">Desired speed.</param>
        /// <param name="force">Desired force.</param>
        public RobotiqSModelBasicCommand(
            bool activation,
            RobotiqSModelGripModes gripMode,
            bool goToPosition,
            byte position,
            byte speed,
            byte force)
        {
            this.Activate = activation;
            this.GripMode = gripMode;
            this.GoToPosition = goToPosition;
            this.Position = position;
            this.Speed = speed;
            this.Force = force;
        }

        /// <summary>
        /// Gets the grip mode
        /// </summary>
        [DataMember]
        public RobotiqSModelGripModes GripMode { get; internal set; }

        /// <summary>
        /// Gets the desired finger position. 
        /// 0 is fully open.
        /// 255 is fully closed.
        /// Exact interpretation is mode dependant
        /// </summary>
        [DataMember]
        public byte Position { get; internal set; }

        /// <summary>
        /// Gets speed of finger movement.
        /// Range is between 22 mm/s (0) and 110 mm/s (255)
        /// </summary>
        [DataMember]
        public byte Speed { get; internal set; }

        /// <summary>
        /// Gets grip force.
        /// Range is between 15 N (0) and 60 N (255)
        /// Relations between this value and N is non-linear.
        /// </summary>
        [DataMember]
        public byte Force { get; internal set; }

        /// <summary>
        /// Gets a value indicating whether to activation.
        /// A value of false will deactivate all motion
        /// Setting to true when the gripper is not active will result in motion (homing routine)
        /// </summary>
        [DataMember]
        public bool Activate { get; internal set; }

        /// <summary>
        /// Gets a value indicating whether to enable go to position.
        /// If true, gripper fingers will try to achieve desired position.
        /// If false, no motion should occur (though motion will occur if gripper is deactivated and then activated)
        /// </summary>
        [DataMember]
        public bool GoToPosition { get; internal set; }
    }
}
